# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=s3rver
pkgver=3.7.1
pkgrel=1
pkgdesc='A fake S3 server written in NodeJs'
arch=('any')
url='https://github.com/jamhall/s3rver'
license=('MIT')
depends=('nodejs')
makedepends=('npm')
source=(https://registry.npmjs.org/$pkgname/-/$pkgname-$pkgver.tgz)
noextract=($pkgname-$pkgver.tgz)
sha512sums=('1fd2885fa9fc36a71fa04e3388535b40048141f8dc34981bfb7c1b4fd2f98a8b44a9f3a77053b5737f1c7c94854a8ef15d3bb5cccf4703ab76bbdc4a36561168')

package() {
  npm install -g --prefix "$pkgdir"/usr "$srcdir"/$pkgname-$pkgver.tgz

  # Non-deterministic race in npm gives 777 permissions to random directories.
  # See https://github.com/npm/npm/issues/9359 for details.
  chmod -R u=rwX,go=rX "$pkgdir"

  # npm installs package.json owned by build user
  # https://bugs.archlinux.org/task/63396
  chown -R root:root "$pkgdir"

  mkdir -p "$pkgdir/usr/share/licenses/$pkgname"
  ln -s "../../../lib/node_modules/$pkgname/LICENSE" "$pkgdir/usr/share/licenses/$pkgname/"
}
